# include<cstring>
# include<stdio.h>
# include<iostream>
# include<algorithm>
# include<cmath>
using namespace std;
int n;
long a,b,x;
long fun()
{
	long start ,end,step;
	step = ((int)pow(10*1.0,(int)log10l(x) + 1) );
	while( ((a-x)%step) != 0)
	{
		a++;
	}
	start = a;

	while(((b-x)%step) != 0)
	{
		b --;
	}
	end = b;

	return ((end -x) - (start-x) )/step  + 1;
}
int main()
{

	scanf("%d",&n);
	while(n--)
	{
		scanf("%ld%ld%ld",&x,&a,&b);
		printf("%ld\n",fun());

	}


	return 0;
}